import LevelInitBase from "../LevelCommon/LevelInitBase";
import LevelControl2 from "../LevelControl/LevelControl2";
import RoomControl from "../LevelCommon/RoomControl";
import { utils } from "../../utils/CommonUtil";
import FocusParentObj from "../Prefabs/InteractivObj/Common/FocusParentObj";
import RotateObj from "../Prefabs/InteractivObj/Common/RotateObj";
import Sound from "../../constant/SoundNameConstant";
import CallToLevel from "../Prefabs/CallToLevel";
import GamePropObj from "../Prefabs/InteractivObj/Common/GamePropObj";
import GasStove from "../Prefabs/InteractivObj/GasStove/GasStove";
import GasButton from "../Prefabs/InteractivObj/GasStove/GasButton";
import GasButtonCheck from "../Prefabs/InteractivObj/GasStove/GasButtonCheck";
import GasFire from "../Prefabs/InteractivObj/GasStove/GasFire";
import FuseBox from "../Prefabs/InteractivObj/Fuse/FuseBox";
import FuseSwitch from "../Prefabs/InteractivObj/Fuse/FuseSwitch";
import Fuse from "../Prefabs/InteractivObj/Fuse/Fuse";
import Gate from "../Prefabs/InteractivObj/Gate";
import MoveObj from "../Prefabs/InteractivObj/Common/MoveObj";
import FocusMoreParentObj from "../Prefabs/InteractivObj/Common/FocusMoreParentObj";
import EnumData from "../../Enum/EnumData";

export default class LevelInit2 extends LevelInitBase {
    private room1: Laya.Sprite3D;
    private container: Laya.Sprite3D;

    public startInitDetail() {
        this.levelRoot.addComponent(LevelControl2);
        this.room1 = this.LevelObjs.getChildByName("room1") as Laya.Sprite3D;
        this.room1.addComponent(RoomControl);
        this.container = this.room1.getChildByName("Container") as Laya.Sprite3D;
        let lignthRoot = this.room1.getChildByName("lignthRoot") as Laya.Sprite3D;
        lignthRoot.active = false;

        let walls = this.room1.getChildByName("walls") as Laya.Sprite3D;
        let wall1 = walls.getChildByName("wall1") as Laya.Sprite3D;
        let wall2 = walls.getChildByName("wall2") as Laya.Sprite3D;
        let wall3 = walls.getChildByName("wall3") as Laya.Sprite3D;
        let wall4 = walls.getChildByName("wall4") as Laya.Sprite3D;

        let GasCookerRoom1 = wall1.getChildByName("GasCookerRoom1") as Laya.Sprite3D;
        let gasFires = GasCookerRoom1.getChildByName("gasFires") as Laya.Sprite3D;
        gasFires.active = false;

        //#region FocusParentObj
        let Icebox = wall1.getChildByName("Icebox") as Laya.Sprite3D;
        let FocusParentObj_Iceboxr = utils.CommonUtils.CustomAddComponent(Icebox, FocusParentObj) as FocusParentObj;
        FocusParentObj_Iceboxr.cameraMoveTime = 1000;
        //#region 

        //#region RotateObj
        let Lower_door_props = Icebox.getChildByName("Lower door_props") as Laya.Sprite3D;
        let RotateObj_Lower_door_props = utils.CommonUtils.CustomAddComponent(Lower_door_props, RotateObj) as RotateObj;
        RotateObj_Lower_door_props.targetRotate = new Laya.Vector3(0, -90, 0);
        RotateObj_Lower_door_props.rotateTime = 500;
        RotateObj_Lower_door_props.isNeedCallToLevel = false;
        RotateObj_Lower_door_props.IsRotateOnce = true;
        RotateObj_Lower_door_props.VoiceName = Sound.soundClipArr.OPEN_GATE;
        RotateObj_Lower_door_props.isConvertUnityRotation = true;

        let Upper_door_props = Icebox.getChildByName("Upper door_props") as Laya.Sprite3D;
        let RotateObjUpper_door_props = utils.CommonUtils.CustomAddComponent(Upper_door_props, RotateObj) as RotateObj;
        RotateObjUpper_door_props.targetRotate = new Laya.Vector3(0, -70, 0);
        RotateObjUpper_door_props.rotateTime = 500;
        RotateObjUpper_door_props.isNeedCallToLevel = false;
        RotateObjUpper_door_props.IsRotateOnce = true;
        RotateObjUpper_door_props.VoiceName = Sound.soundClipArr.OPEN_GATE;
        RotateObjUpper_door_props.isConvertUnityRotation = true;
        //#endregion

        //#region GamePropObj
        let jinianpin = wall1.getChildByName("jinianpin") as Laya.Sprite3D;
        let GamePropObj_jinianpin = utils.CommonUtils.CustomAddComponent(jinianpin, GamePropObj) as GamePropObj;
        GamePropObj_jinianpin.gamePropId = 11;

        let jinianpin2 = wall1.getChildByName("jinianpin (2)") as Laya.Sprite3D;
        let GamePropObj_jinianpin2 = utils.CommonUtils.CustomAddComponent(jinianpin2, GamePropObj) as GamePropObj;
        GamePropObj_jinianpin2.gamePropId = 11;

        let Doll_dog_props = wall1.getChildByName("Doll dog_props") as Laya.Sprite3D;
        let GamePropObj_Doll_dog_props = utils.CommonUtils.CustomAddComponent(Doll_dog_props, GamePropObj) as GamePropObj;
        GamePropObj_Doll_dog_props.gamePropId = 9;


        //#endregion

        //#region CallToLevel
        let checkFridgeGarbage = Icebox.getChildByName("checkFridgeGarbage") as Laya.Sprite3D;
        let CallToLevel_checkFridgeGarbage = utils.CommonUtils.CustomAddComponent(checkFridgeGarbage, CallToLevel) as CallToLevel;

        //#endregion

        //#region GasStove 煤气灶
        let GasStove_GasCookerRoom1 = utils.CommonUtils.CustomAddComponent(GasCookerRoom1, GasStove) as GasStove;
        GasStove_GasCookerRoom1.isNeedCallToLevel = true;
        GasStove_GasCookerRoom1.isInteractive = false;
        GasStove_GasCookerRoom1.cameraMoveTime = 1000;

        let gasButton = GasCookerRoom1.getChildByName("gasButton") as Laya.Sprite3D;
        gasButton.active = false;
        let GasButton_gasButton = utils.CommonUtils.CustomAddComponent(gasButton, GasButton) as GasButton;
        GasButton_gasButton.targetRotate = new Laya.Vector3(0, 0, -4);
        GasButton_gasButton.rotateTime = 500;
        GasButton_gasButton.IsRotateOnce = false;

        let gasButtonCheck = GasCookerRoom1.getChildByName("gasButtonCheck") as Laya.Sprite3D;
        let GasButtonCheck_gasButton = utils.CommonUtils.CustomAddComponent(gasButtonCheck, GasButtonCheck) as GasButtonCheck;
        GasButtonCheck_gasButton.needGamePropId = 10;

        let gasFire1 = gasFires.getChildByName("gasFire1") as Laya.Sprite3D;
        let GasFire_gasFire1 = utils.CommonUtils.CustomAddComponent(gasFire1, GasFire) as GasFire;
        GasFire_gasFire1.needFirePropId = 9;
        GasFire_gasFire1.getPropId = 2;
        //#endregion

        //#region fuse 保险丝
        let fuseBoxRoom1 = wall2.getChildByName("fuseBoxRoom1") as Laya.Sprite3D;
        let FuseBox_fuseBoxRoom1 = utils.CommonUtils.CustomAddComponent(fuseBoxRoom1, FuseBox) as FuseBox;

        let fuseSwitchRoom1 = fuseBoxRoom1.getChildByName("fuseSwitchRoom1") as Laya.Sprite3D;
        let FuseSwitch_fuseSwitchRoom1 = utils.CommonUtils.CustomAddComponent(fuseSwitchRoom1, FuseSwitch) as FuseSwitch;
        FuseSwitch_fuseSwitchRoom1.targetRotateAngle = new Laya.Vector3(90, 0, -90);

        let fuses = fuseBoxRoom1.getChildByName("fuses") as Laya.Sprite3D;
        let Fuse_fuses = utils.CommonUtils.CustomAddComponent(fuses, Fuse) as Fuse;
        Fuse_fuses.needPropId = 1;
        //#endregion

        //#region gate 门
        let gateRoom1 = wall2.getChildByName("gateRoom1") as Laya.Sprite3D;
        let Gate_gateRoom1 = utils.CommonUtils.CustomAddComponent(gateRoom1, Gate) as Gate;
        Gate_gateRoom1.needPropId = 2;
        Gate_gateRoom1.Axis = EnumData.Axis.X;
        Gate_gateRoom1.Angle = 60;
        //#endregion

        //#region Cupboard 橱柜
        let Cupboard = wall3.getChildByName("Cupboard") as Laya.Sprite3D;
        let FocusParentObj_Cupboard = utils.CommonUtils.CustomAddComponent(Cupboard, FocusParentObj) as FocusParentObj;

        let drawer01_props = Cupboard.getChildByName("drawer01_props") as Laya.Sprite3D;
        let MoveObj_drawer01_props = utils.CommonUtils.CustomAddComponent(drawer01_props, MoveObj) as MoveObj;
        MoveObj_drawer01_props.targetPos = new Laya.Vector3(1.189984, 0.6380273, 2.5);
        MoveObj_drawer01_props.VoiceName = "openChouTi";
        MoveObj_drawer01_props.isConvertUnityPosition = true;

        let drawer02_props = Cupboard.getChildByName("drawer02_props") as Laya.Sprite3D;
        let MoveObj_drawer02_props = utils.CommonUtils.CustomAddComponent(drawer02_props, MoveObj) as MoveObj;
        MoveObj_drawer02_props.targetPos = new Laya.Vector3(-1.189981, 0.6380273, 2.5);
        MoveObj_drawer02_props.VoiceName = "openChouTi";
        MoveObj_drawer02_props.isConvertUnityPosition = true;

        let drawer03_props = Cupboard.getChildByName("drawer03_props") as Laya.Sprite3D;
        let MoveObj_drawer03_props = utils.CommonUtils.CustomAddComponent(drawer03_props, MoveObj) as MoveObj;
        MoveObj_drawer03_props.targetPos = new Laya.Vector3(1.189984, -0.016, 2.5);
        MoveObj_drawer03_props.VoiceName = "openChouTi";
        MoveObj_drawer03_props.isConvertUnityPosition = true;

        let baoxiansi2_1 = drawer03_props.getChildByName("baoxiansi2 (1)") as Laya.Sprite3D;
        let GamePropObj_baoxiansi2_1 = utils.CommonUtils.CustomAddComponent(baoxiansi2_1, GamePropObj) as GamePropObj;
        GamePropObj_baoxiansi2_1.gamePropId = 1;
        //#endregion

        //#region Table 中间桌子
        let Table = this.container.getChildByName("Table") as Laya.Sprite3D;
        let FocusMoreParentObj_Table = utils.CommonUtils.CustomAddComponent(Table, FocusMoreParentObj) as FocusMoreParentObj;

        let valve_props = Table.getChildByName("valve_props") as Laya.Sprite3D;
        let GamePropObj_valve_props = utils.CommonUtils.CustomAddComponent(valve_props, GamePropObj) as GamePropObj;
        GamePropObj_valve_props.gamePropId = 10;

        let jinianpin_1 = this.container.getChildByName("jinianpin (1)") as Laya.Sprite3D;
        let GamePropObj_jinianpin_1 = utils.CommonUtils.CustomAddComponent(jinianpin_1, GamePropObj) as GamePropObj;
        GamePropObj_jinianpin_1.gamePropId = 11;
        //#endregion
    }
}